﻿begin tran
	set tran isolation level SERIALIZABLE;
	declare @User nvarchar(50)
	select @User=Username from NguoiDung with (UPDLOCK) where Username='haha'
	if(@User is not null)
	begin
		raiserror(N'Username đã tồn tại',10,1)
		rollback tran
		return
	end
	insert into NguoiDung(Username,Password,TenNguoiDung,NgaySinh,Email,DiaChi,DienThoai,IDLoaiNguoiDung,DiemThuong,IDDaiLy) values('haha','123456','Nhu','10/29/1985','dsgvsdgv','fhfdh','5454',3,0,null)
	if(@@ERROR<>0)
	begin
		raiserror(N'Đã có lỗi trong quá trình đăng ký tài khoản',10,1)
		rollback tran
		return
	end
commit tran